import { createRouter, createWebHistory } from 'vue-router'

import Layout from '../layout/index.vue'

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        component: () => import('../views/dashboard.vue'),
        name: 'Dashboard',
        meta: { title: '仪表盘', icon: 'Odometer' }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    name: 'System',
    meta: { title: '系统管理', icon: 'Setting' },
    children: [
      {
        path: '/system/user',
        component: () => import('../views/system/user.vue'),
        name: 'User',
        meta: { title: '用户管理', icon: 'User' }
      },
      {
        path: '/system/role',
        component: () => import('../views/system/role.vue'),
        name: 'Role',
        meta: { title: '角色管理', icon: 'UserFilled' }
      },
      {
        path: '/system/permission',
        component: () => import('../views/system/permission.vue'),
        name: 'Permission',
        meta: { title: '权限管理', icon: 'Lock' }
      },
      {
        path: '/system/department',
        component: () => import('../views/system/department.vue'),
        name: 'Department',
        meta: { title: '部门管理', icon: 'OfficeBuilding' }
      }
    ]
  },
  {
    path: '/content',
    component: Layout,
    name: 'Content',
    meta: { title: '内容管理', icon: 'Document' },
    children: [
      {
        path: '/content/article',
        component: () => import('../views/content/article.vue'),
        name: 'Article',
        meta: { title: '文章管理', icon: 'Document' }
      },
      {
        path: '/content/category',
        component: () => import('../views/content/category.vue'),
        name: 'Category',
        meta: { title: '分类管理', icon: 'Files' }
      },
      {
        path: '/content/tag',
        component: () => import('../views/content/tag.vue'),
        name: 'Tag',
        meta: { title: '标签管理', icon: 'Collection' }
      }
    ]
  },
  {
    path: '/log',
    component: Layout,
    name: 'Log',
    meta: { title: '日志管理', icon: 'List' },
    children: [
      {
        path: '/log/operation',
        component: () => import('../views/log/operation.vue'),
        name: 'Operation',
        meta: { title: '操作日志', icon: 'List' }
      },
      {
        path: '/log/login',
        component: () => import('../views/log/login.vue'),
        name: 'Login',
        meta: { title: '登录日志', icon: 'Timer' }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
